<?php

/**
 * Created by PhpStorm.
 * User: d7
 * Date: 2016/1/8
 * Time: 9:21
 */
class Account extends MY_View_Controller
{
    function __construct()
    {
        parent::__construct();
    }

    function index(){
        $this->load->model('users/User_model');
        $user = $this->User_model->get_user_by_id($this->_login_user['user_id']);
        $this->assign('user',$user);
        $this->display();
    }

    function do_update(){
        $user_id = $this->_login_user['user_id'];
        $data = array(
            'id'        =>  $user_id,
            'username'  =>  $this->input->post('username'),
            'nickname'  =>  $this->input->post('nickname'),
            'gender'    =>  $this->input->post('gender'),
            'tags'      =>  $this->input->post('tags'),
            'avatar'    =>  $this->input->post('avatar'),
            'introduce' =>  $this->input->post('introduce'),
            'birthday'  =>  $this->input->post('year').'-'.$this->input->post('month').'-'.$this->input->post('day')
        );
        $this->load->model('users/User_model');
        if($this->User_model->update($data)){
            $this->json_response(true);
        }
        $this->json_response(false);
    }
}